import java.util.Random;

public class Test1 {
    public static int sum=0;
    public static void main(String[] args) throws InterruptedException {
        long time1=System.currentTimeMillis();
        int[] arr=new int[100];
        Random random=new Random();
        for(int i=0;i<100;i++){
            arr[i] =random.nextInt(100);
        }
        Thread t1=new Thread(()->{

           int sum1=0;
           for(int i=0;i<100;i+=2){
               sum1+=arr[i];
           }
           sum+=sum1;
        });

        Thread t2=new Thread(()->{

            int sum2=0;
            for(int i=1;i<100;i+=2){
                sum2+=arr[i];
            }
            sum+=sum2;
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();
        long time2= System.currentTimeMillis();

        System.out.println(sum);
        System.out.println(time2-time1);
    }
}
